use actix_web::web::Json;
use apistos::ApiComponent;
use schemars::JsonSchema;
use serde::Deserialize;

#[derive(Deserialize, Debug, JsonSchema, ApiComponent)]
pub struct CreateTodoParam {
    pub title: String,
    pub description: String,
}

impl From<Json<CreateTodoParam>> for CreateTodoParam {
    fn from(param: Json<CreateTodoParam>) -> Self {
        CreateTodoParam {
            title: param.title.to_owned(),
            description: param.description.to_owned(),
        }
    }
}

#[derive(Deserialize, Debug, JsonSchema, ApiComponent)]
pub struct UpdateTodoParam {
    pub title: String,
    pub description: String,
}

#[derive(Deserialize, Debug, JsonSchema, ApiComponent)]
pub struct UpdateTodoStatusParam {
    pub status: String,
}
